﻿

using System.Web.UI.WebControls;

namespace EventManager.DataMigrations
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using Orchard.ContentManagement.Drivers;
    using Orchard.ContentManagement.MetaData;
    using Orchard.ContentManagement.MetaData.Builders;
    using Orchard.Core.Contents.Extensions;
    using Orchard.Data.Migration;
    using Maps.Models;
    using Models;
    using Orchard.Indexing;


    public class Migrations : DataMigrationImpl
    {

        public int Create()
        {
            // Creating table MemberEventPartRecord
            SchemaBuilder.CreateTable("MemberEventPartRecord", table => table
                .ContentPartRecord()
                .Column("Date", DbType.String)
                .Column("Location", DbType.String)
                .Column("Attendees", DbType.String)
                .Column("Description", DbType.String)
            );


            ContentDefinitionManager.AlterPartDefinition("MemberEventPart",
              builder => builder.Attachable()
              .WithLocation(new Dictionary<string, ContentLocation>
              {
              {"Default", new ContentLocation {Zone = "primary", Position = "3"}},
              {"Editor", new ContentLocation {Zone = "primary", Position = "3"}}
    }));

            ContentDefinitionManager.AlterTypeDefinition("MemberEvent",
             cfg => cfg.WithPart("CommonPart")
            .WithPart("TitlePart")
            .WithPart("MemberEventPart")
            .WithPart("ContainablePart")
            .WithPart("MenuPart")
        //    .WithPart(typeof(Menu).Name)
            .WithPart("MapPart")
            .Draftable()
            .Creatable()
            .Indexed());

            return 1;
        }

    }
}